package com.xsh.gls.controller;

import com.xsh.gls.pojo.Company;
import com.xsh.gls.pojo.Transfer;
import com.xsh.gls.pojo.Ycon;
import com.xsh.gls.service.CompanyService;
import com.xsh.gls.service.YconService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/ycon")
public class YconController {
    @Autowired
    private YconService yconService;
    @Autowired
    private CompanyService companyService;

    @RequestMapping("/select")
    public Object select(){
        List<Company> companyList=companyService.select();
        System.out.println(companyList.get(0).getcName());
        return companyList;

    }

    @RequestMapping("/update")
    public Transfer add(Ycon ycon){
        System.out.println(ycon);
        Transfer transfer=new Transfer();
        int count=yconService.add(ycon);
        if (count==1){
            System.out.println("保存成功");
            transfer.setMessage("yes");
        }else{
            System.out.println("保存失败");
            transfer.setMessage("no");
        }
        return transfer;
    }

}
